package com.sondon.mayi.adapter;

import java.util.ArrayList;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import com.sondon.mayi.entity.ScoreRecord;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

/**
 * @Project : Fruit
 * @Package : com.sondon.mayi.adapter
 * @Class : ScoreRecordList
 * @Author : 蔡文锋
 * @DateTime：2015年7月3日 下午9:47:08
 * @Blog：http://blog.csdn.net/caiwenfeng_for_23
 * @Description : {  积分记录列表 }
 */
@EBean
public class ScoreRecordListAdapter extends BaseAdapter {
	@RootContext
	Context context;
	ArrayList<ScoreRecord> datas=new ArrayList<ScoreRecord>();
	
	public void SetDatas(ArrayList<ScoreRecord> datas){
		this.datas.clear();
		if(datas!=null&&datas.size()>0){
			this.datas.addAll(datas);
		}
		notifyDataSetChanged();
	}
	
	public ArrayList<ScoreRecord> GetDatas(){
		return this.datas;
	}
	
	@Override
	public int getCount() {

		return this.datas.size();
	}

	@Override
	public Object getItem(int position) {

		return this.datas.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ScoreRecordList_Item item;
		if(convertView==null){
			item=ScoreRecordList_Item_.build(this.context);
		}else{
			item=(ScoreRecordList_Item) convertView;
		}
		item.bind(this.datas.get(position));
		return item;
	}

//	//设置Listview是否可点击
//	@Override
//	public boolean isEnabled(int position) {
//		return false;
//	}
}
